﻿global using SimpleServer;
global using static System.Console;

var signal = new AutoResetEvent(false);

Server.Notify = str => WriteLine(str);
Server.OnError = ex =>
{
	WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
	if (ex.Message == "没有合适的端口") signal.Set();
};

try
{
	Server.Run();
	WriteLine("正在运行...");
	signal.WaitOne();
}
catch(Exception ex)
{
	WriteLine("出错了");
	WriteLine(ex.Message);
	WriteLine(ex.StackTrace);
}

WriteLine("已退出");
